PATHMac OS 8 and 9 Developer Documentation > Networking and Communications > URL Access Manager >

Transferring Files With the URL Access Manager


URLUpload

Uploads a file or directory synchronously to an FTP URL using a URL reference.

OSStatus URLUpload (
                     URLReference urlRef,
                     const FSSpec* source,
                     URLOpenFlags openFlags,
                     URLSystemEventProcPtr eventProc,
                     void* userContext);
urlref
A reference of type URLReference that specifies the URL to which this file or directory is to be uploaded. Call URLNewReference to create the reference.
source
A pointer to a structure of type FSSpec . Before calling URLUpload , set the structure to specify the file you want to upload. See Inside Macintosh: Files for more information about the FSSpec structure.
openFlags
A value of type URLOpenFlags that specifies upload options. The following constants can be used to specify upload options:
kURLReplaceExistingFlag kURLBinHexFileFlag kURLDisplayProgressFlag kURLDisplayAuthFlag kURLDoNotTryAnonymousFlag
See Open Flag Constants for descriptions of these constants.
eventProc
A value of type URLSystemEventProcPtr which points to an application-defined system event callback routine System Event Callback Routine that the URL Access Manager calls to communicate system events to your application during the upload process. If your application requests the display of a progress indicator or authentication dialog blox, these items appear in a movable modal dialog box.
The value of eventProc can be NULL , in which case your application will not be informed of system events. If your application requests the display of a progress indicator or authentication dialog box, these items appear in a non-movable modal dialog box.
userContext
An untyped pointer to arbitrary data that the URL Access Manager passes to the application-defined system event callback routine specified by eventProc . Your application can use userContext to associate a callback with a particular call to URLUpload .
function result
A result code. For a list of possible result codes, see Result Codes .

DISCUSSION

The URLUpload function uploads data synchronously to the specified FTP URL from the specified file or directory and does not return until the upload is complete. The URLUpload function yields time to other threads. Your application should call URLUpload from a thread other than the main thread so that other processes have time to run.

If you want a progress indicator to be displayed during the upload, specify kURLDisplayProgressFlag in the openFlags parameter. The URL Access Manager uses a modal dialog box to display the progress indicator. If your application has multiple threads, it can call URLUpload multiple times, but if it calls URLUpload with kURLDisplayProgressFlag set in openFlags when the URL Access Manager is already displaying a modal dialog box, URLUpload returns the error kURLProgessAlreadyDisplayedError .

If the URL identified by the urlRef parameter is a file, the file is uploaded regardless of whether kURLDirectoryListingFlag or KURLIsDirectoryHintFlag is set in the openFlags parameter.

WARNING

Once you call URLUpload with urlRef , you cannot use the same urlRef to call URLUpload again, or to call URLDownlload or URLOpen . If you need to call URLUpload , URLDownload , or URLOpen with a urlRef that has already been used for one of these calls, you need to create a new URL reference by calling URLNewReference .

Call URLOpen if you need to control the upload process.


© 1999 Apple Computer, Inc. – (Last Updated 07 May 99)